﻿using PHMEE.ToolKits;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE
{
    /// <summary>
    /// 主柴油发电机机组
    /// </summary>
    public class MainGeneratorUnit : Unit
    {
        protected MainGeneratorUnit()
        {

        }

        public MainGeneratorUnit(Guid id, Guid vesselId, string name, string nameen, int number) : base(id, vesselId, name, nameen, number)
        {

        }

        /// <summary>
        /// 柴油机端加速度峰值阈值
        /// </summary>
        [NotMapped]
        public double Acc { get; set; }

        /// <summary>
        /// 柴油机曲轴端加速度rms阈值
        /// </summary>
        [NotMapped]
        public double QZAccRms { get; set; }

        /// <summary>
        /// 柴油机气缸端加速度rms阈值
        /// </summary>
        [NotMapped]
        public double QGAccRms { get; set; }

        /// <summary>
        /// 柴油机轴瓦加速度rms阈值
        /// </summary>
        [NotMapped]
        public double ZWAccRms { get; set; }

        /// <summary>
        /// 柴油机端速度rms阈值
        /// </summary>
        [NotMapped]
        public double DRms { get; set; }

        /// <summary>
        /// 发电机端速度rms阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double GRmsA { get; set; }

        /// <summary>
        /// 发电机端速度rms阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double GRmsB { get; set; }

        /// <summary>
        /// 发电机端速度rms阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double GRmsC { get; set; }


        /// <summary>
        /// 发电机端轴瓦磨损故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double GBushBearA { get; set; }

        /// <summary>
        /// 发电机端轴瓦磨损故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double GBushBearB { get; set; }

        /// <summary>
        /// 发电机端轴瓦磨损故障判断阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double GBushBearC { get; set; }

        /// <summary>
        /// 发电机端轴瓦磨损故障判断阈值
        /// 4
        /// </summary>
        [NotMapped]
        public double GBushBearD { get; set; }

        /// <summary>
        /// 发电机端轴瓦磨损故障判断阈值
        /// 5
        /// </summary>
        [NotMapped]
        public double GBushBearE { get; set; }

        /// <summary>
        /// 发电机端轴瓦磨损故障判断阈值
        /// 6
        /// </summary>
        [NotMapped]
        public double GBushBearF { get; set; }

        /// <summary>
        /// 柴油机端共振故障判断阈值
        /// </summary>
        [NotMapped]
        public double ResonanceFault { get; set; }

        /// <summary>
        /// 柴油机端结构松动故障判断阈值
        /// </summary>
        [NotMapped]
        public double StructureLoose { get; set; }

        /// <summary>
        /// 联轴器失中阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double CouplingMisalignmentA { get; set; }

        /// <summary>
        /// 联轴器失中阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double CouplingMisalignmentB { get; set; }

        /// <summary>
        /// 点火频率幅值阈值
        /// </summary>
        [NotMapped]
        public double ValueLgnition { get; set; }

        /// <summary>
        /// 发电机端判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double Value1XA { get; set; }

        /// <summary>
        /// 发电机端判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double Value1XB { get; set; }

        /// <summary>
        /// 发电机电枢故障判断阈值
        /// </summary>
        [NotMapped]
        public double ArmatureFault { get; set; }

        /// <summary>
        /// 柴油机机端轴瓦磨损故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double DBushBearA { get; set; }

        /// <summary>
        /// 柴油机机端轴瓦磨损故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double DBushBearB { get; set; }


        /// <summary>
        /// 柴油机机端轴瓦磨损故障判断阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double DBushBearC { get; set; }


        /// <summary>
        /// 柴油机机端轴瓦磨损故障判断阈值
        /// 4
        /// </summary>
        [NotMapped]
        public double DBushBearD { get; set; }

        /// <summary>
        /// 柴油机机端轴瓦磨损故障判断阈值
        /// 5
        /// </summary>
        [NotMapped]
        public double DBushBearE { get; set; }

        /// <summary>
        /// 柴油机机端轴瓦磨损故障判断阈值
        /// 6
        /// </summary>
        [NotMapped]
        public double DBushBearF { get; set; }


        /// <summary>
        /// 柴油机轴径磨损故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double ZJWearFaultA { get; set; }

        /// <summary>
        /// 柴油机轴径磨损故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double ZJWearFaultB { get; set; }

        /// <summary>
        /// 柴油机轴径磨损故障判断阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double ZJWearFaultC { get; set; }

        /// <summary>
        /// 柴油机轴径磨损故障判断阈值
        /// 4
        /// </summary>
        [NotMapped]
        public double ZJWearFaultD { get; set; }

        /// <summary>
        /// 柴油机轴径磨损故障判断阈值
        /// 5
        /// </summary>
        [NotMapped]
        public double ZJWearFaultE { get; set; }

        /// <summary>
        /// 柴油机轴径磨损故障判断阈值
        /// 6
        /// </summary>
        [NotMapped]
        public double ZJWearFaultF { get; set; }


        /// <summary>
        /// 柴油机气缸磨损故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double QGWearFaultA { get; set; }

        /// <summary>
        /// 柴油机气缸磨损故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double QGWearFaultB { get; set; }

        /// <summary>
        /// 柴油机气缸磨损故障判断阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double QGWearFaultC { get; set; }

        /// <summary>
        /// 柴油机气缸磨损故障判断阈值
        /// 4
        /// </summary>
        [NotMapped]
        public double QGWearFaultD { get; set; }

        /// <summary>
        /// 柴油机气缸磨损故障判断阈值
        /// 5
        /// </summary>
        [NotMapped]
        public double QGWearFaultE { get; set; }

        /// <summary>
        /// 柴油机气缸磨损故障判断阈值
        /// 6
        /// </summary>
        [NotMapped]
        public double QGWearFaultF { get; set; }


        public override void SerializeProperties(Dictionary<string, object> derivedPropertiesJson)
        {
            var properties = PHMEECoreHelper.GetDerivedProperties(this);
            this.DerivedPropertiesJson = derivedPropertiesJson.Where(item => properties.Keys.Any(p => string.Equals(p, item.Key, StringComparison.OrdinalIgnoreCase))).ToDictionary();
        }

        public override void DeserializeProperties()
        {
            PHMEECoreHelper.SetDerivedProperties(this, DerivedPropertiesJson);
        }

        public override Dictionary<string, object> InitDefaultProperties()
        {
            Dictionary<string, object> dict = new Dictionary<string, object>
            {
                { nameof(Acc), 15.0 },
                { nameof(QZAccRms), 4.42 },
                { nameof(QGAccRms), 4.42 },
                { nameof(ZWAccRms), 4.42 },
                { nameof(DRms), 11.2 },
                { nameof(GRmsA), 7.1 },
                { nameof(GRmsB), 7.1 },
                { nameof(GRmsC), 7.1 },
                { nameof(GBushBearA), 0.6 },
                { nameof(GBushBearB), 0.3 },
                { nameof(GBushBearC), 0.3 },
                { nameof(GBushBearD), 0.3 },
                { nameof(GBushBearE), 0.3 },
                { nameof(GBushBearF), 0.3 },
                { nameof(ResonanceFault), 0.7 },
                { nameof(StructureLoose), 0.7 },
                { nameof(CouplingMisalignmentA), 0.7 },
                { nameof(CouplingMisalignmentB), 0.3 },
                { nameof(ValueLgnition), 40.0 },
                { nameof(Value1XA), 30.0 },
                { nameof(Value1XB), 30.0 },
                { nameof(ArmatureFault), 0.7 },
                { nameof(DBushBearA), 0.0 },
                { nameof(DBushBearB), 0.0 },
                { nameof(DBushBearC), 0.0 },
                { nameof(DBushBearD), 0.0 },
                { nameof(DBushBearE), 0.0 },
                { nameof(DBushBearF), 0.0 }
            };

            return dict;

        }
    }
}
